package com.hmkj.admin.controller.operate;

import com.hmkj.admin.controller.BaseController;
import com.hmkj.admin.utils.AdminSessionHelper;
import com.hmkj.core.po.operate.Agent;
import com.hmkj.core.po.system.Admin;
import com.hmkj.core.service.operate.AgentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/*
                          _.._        ,------------.
                       ,'      `.    ( hello gays,your code never bug.... )
                      /  __) __` \    `-,----------'
                     (  (`-`(-')  ) _.-'
                     /)  \  = /  (
                    /'    |--' .  \
                   (  ,---|  `-.)__`
                    )(  `-.,--'   _`-.
                   '/,'          (  fk",
                    (_       ,    `/,-' )
                    `.__,  : `-'/  /`--'
                      |     `--'  |
                      `   `-._   /
                       \        (
                       /\ .      \.
                      / |` \     ,-\
                     /  \| .)   /   \
                    ( ,'|\    ,'     :
                    | \,`.`--"/      }
                    `,'    \  |,'    /
                   / "-._   `-/      |
                   "-.   "-.,'|     ;
                  /        _/["---'""]
                 :        /  |"-     '
                 '           |      /
                             `      |
*/
/**
 * Banner管理
 */
@Controller
@RequestMapping(BaseController.BASE_URI)
public class BannerController extends BaseController {

    @Resource
    private AgentService agentService;

    @RequestMapping("/banner/list")
    public String list(ModelMap modelMap) {
        Admin admin = AdminSessionHelper.getCurrAdmin();
        List<Agent> agents ;
        if(admin.getType()==Admin.TYPE.T3.code){
            agents  = agentService.select(new Agent(agent -> {
                agent.setId(admin.getBussId());
                agent.setDelFlag(Agent.DELFLAG.NORMAL.code);
            }));
        }else{
            agents  = agentService.select(new Agent(agent -> {
                agent.setDelFlag(Agent.DELFLAG.NORMAL.code);
            }));
        }
        modelMap.put("agents", agents);
        modelMap.put("type",admin.getType());
        return ok("operate/banner/list");
    }

}
